package com.csust.automaticteach.controller;

import com.csust.opration.logger.annotation.LogOperation;
import com.csust.opration.logger.core.model.OperationUser;
import com.csust.opration.logger.core.userinfo.LogUserInfoAdapter;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import static com.csust.opration.logger.constant.CommonConstant.VIEW;

/**
 * @ClassNameHealthController
 * @Description TODO
 * @Author钰玟
 * @Date2025/5/31 下午12:03
 * @Version 1.0
 **/

@RestController
@RequestMapping("/health")
@Slf4j
public class HealthController {
    @Resource
    private LogUserInfoAdapter loginLogUser;
    @PostMapping("/check")
    @LogOperation(menu = "健康检查", type = VIEW, content = "'发起请求:'+{#user.username}")
    public String health(@RequestBody OperationUser user) {
        System.out.println(user.getUsername());
        return user.getUsername();
    }




    /**
     * langChain4j调用IflyTek
     * @param message
     * @return
     * @throws SparkClientException
     */
//    @Resource
//    private AiCodeGeneratorService aiCodeGeneratorService;
//
//    @GetMapping(value = "/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)//
//    public Flux<String> stream(@RequestParam("message") String message) throws SparkClientException {
//        Flux<String> stringFlux = aiCodeGeneratorService.generateHTMLStream(message);
//        return stringFlux;
//    }
//    @GetMapping(value = "/call", produces = MediaType.TEXT_EVENT_STREAM_VALUE)//
//    public String call(@RequestParam("message") String message) throws SparkClientException {
//        String stringFlux = aiCodeGeneratorService.generateHTML(message);
//        return stringFlux;
//    }


//    private final ChatClient chatClient;
//    public HealthController(ChatModel openAiChatModel) {
//        ChatMemory chatMemory = new InMemoryChatMemory();
//        this.chatClient = ChatClient.builder(openAiChatModel)
////                .defaultSystem("你是助手")//系统预设
//                .defaultAdvisors(new MessageChatMemoryAdvisor(chatMemory),//添加对话记忆advisor
////                        new SimpleLoggerAdvisor()//添加系统自带的日志advisor
//                        new MyLoggerAdvisor() //添加自定义日志advisor
//                )
//                .build();
//    }
    /**
     * Spring Ai  调用ds
     * @param message
     * @return
     * @throws SparkClientException
     */
//    @GetMapping(value = "/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)//
//    public Flux<String> stream(@RequestParam("message") String message) throws SparkClientException {
//        Flux<String> content = chatClient.prompt().user(message).stream().content();
//        return content;
//    }


//        private final ChatClient chatClient;
//    public HealthController(ChatModel dashscopeChatModel) {
//        ChatMemory chatMemory = new InMemoryChatMemory();
//        this.chatClient = ChatClient.builder(dashscopeChatModel)
////                .defaultSystem("你是助手")//系统预设
//                .defaultAdvisors(new MessageChatMemoryAdvisor(chatMemory),//添加对话记忆advisor
////                        new SimpleLoggerAdvisor()//添加系统自带的日志advisor
//                        new MyLoggerAdvisor() //添加自定义日志advisor
//                )
//                .build();
//    }
//    @GetMapping(value = "/multi_model")//
//    public String multiModel(@RequestParam("message") String message,String modelType){
////        .withEnableSearch(true)
//        DashScopeChatOptions chatOptions = DashScopeChatOptions.builder().withModel(modelType).build();
//        Prompt prompt = new Prompt(message, chatOptions);
//        ChatResponse response = chatClient.prompt(prompt).call().chatResponse();
//        return response.getResult().getOutput().getText();
//
//    }


}


